.TH setpib 1 "November 2013" "open-plc-utils-0.0.3" "Qualcomm Atheros Open Powerline Toolkit"

.SH NAME
setpib - Qualcomm Atheros PIB File Editor 

.SH SYNOPSIS
.BR setpib 
.RI [ options ]
.IR file 
.IR base 
.RI [ type 
.IR data ]
.RI [ type
.IR data ]
[...] 

.SH DESCRIPTION
Replace one or more values in a Qualcomm Atheros powerline parameter (or \fBPIB\fR) file and re-compute the checksum.
Values are specified as a sequence of type/data pairs.
Users must know the offset, length and type of the values they change or problems will certainly result.
This program makes absolutely no effort to validate offsets or values.

.PP
This program can be used to change any PIB value, including those that should not be changed.
Be warned that some PIB values are derived from, or interact with, other PIB values.
Failure to observe such dependencies may diminish performance or render a device inoperable.

.PP
Atheros does not recommend the use of this program to edit PIB parameters because small mistakes can cause big problems.
In addition, Atheros is under no obligation to provide customers with the offset, length or type of any PIB file parameters.

.PP
Atheros recommends using program \fBmodpib\fR to change device identity parameters and the Windows Device Manager to change other parameters whenever possible.

.PP
This program handles older Thunderbolt/Lightning parameter files and newer Panther/Lynx parameter files but it has a larger footprint that may not be acceptable for embedded systems.
In cases where only the older or the newer parameter files are used, consider using program \fBsetpib1\fR for an older Thunderbolt/Lightning\fR only version or \fBsetpib2\fR for a newer Panther/Lynx only version.

.PP
This program is part of the Qualcomm Atheros Powerline Toolkit.
See the \fBAMP\fR man page for an overview and installation instructions.

.SH OPTIONS

.TP
.RB - q
Enable quiet mode which has not effect.

.TP
.RB - v 
Print a hexdump of the edited region.
Print hexdump headers if this option appears twice.
The region window may be changed with option \fB-w\fR.

.TP
-\fBw \fIwindow\fR
The display window in bytes.
When option \fB-v\fR is present, PIB information surrounding the edited region is displayed to provide some sort of context.
The edited region appears in the middle of this window.
The default \fBwindow\fR is \fB32\fR bytes.
This means that the 32 bytes before and the 32 bytes after the edited region are included in the display.

.TP
.RB - x
Repair the checksum.
By default, this program does not modify files that fail the size or checksum test on input.
In addition, it does not re-compute the checksum on output if no data has changed.
This option skips the size and checksum test on input and re-computes the checksum on output even if no data has changed.
This option only works on legacy PIB files.
It does not work on PIB files having NVM file format.

.TP
-\fB?\fR, --\fBhelp\fR
Print program help summary on stdout.
This option takes precedence over other options on the command line.

.TP
-\fB!\fR, --\fBversion\fR
Print program version information on stdout.
This option takes precedence over other options on the command line.
Usethis option when sending screen dumps to Atheros Technical Support so that they know exactly which version of the Linux Toolkit you are using.

.SH ARGUMENTS

.TP
.IR file
The PIB filename.
The file must exist and will be re-written.
No assumptions are made based on filename and no filename conventions are enforced.
This argument is required and must precede the \fBbase\fR argument.

.TP
.IR base
The byte offset where changes will start.
The offset is expressed in hexadecimal with (or without) the leading "\fB0x\fR".
Changes are applied in order, left to right, and offset automatically increments by the correct amount after each change is applied.
This permits consectuive PIB locations to be changed with one command.
This argument is required and must follow the \fBfile\fR argument.
It must also precede all format/data pairs.
Normally, you must use multiple \fBsetpib\fR commands to change non-consecutive PIB locations but careful use of format \fBskip\fR can achive the same results using one command.

.TP
.IB type
The implied length and encoding of the data.
Valid types are \fBbyte\fR, \fBword\fR, \fBlong\fR, \fBdata\fR and \fBhfid\fR.
A valid format must precede each data item.
A byte is 8 bits, a word is 16 bits, a long is 32 bits and a huge is 64 bits.
The format implies the maximum data value except for format \fBdata\fR which is limited by the number of octets entered on the command line.

.TP
.IB data
The information written to the current PIB offset.
Integer data may be expressed in binary, decimal or hexadecimal but must not exceed the \fBtype\fR minimum or maximum.
String data may contain any ASCII characters that can be entered via keyboard but must be enclosed in quotes when spaces are included.
Binary values start with \fB0b\fR or \fB0B\fR and hexadecimal values start with \fB0x\fR or \fB0X\fR.

.SH FORMATS

.TP
\fBbyte \fIinteger\fR
A signed or unsigned integer stored as 8 bits or 1 byte.
The value is expressed in decimal by default.
A binary value may be expressed with a \fB0b\fR prefix.
A hexadecimal value may be expressed using a \fB0x\fR prefix.
Negative type/data values must appear at the end of the command line, after option "\fB--\fR", to avoid parsing errors.
The offset increments by 1 prior to the next insertion.

.TP
\fBword \fIinteger\fR
A signed or unsigned integer stored as 16 bits or 2 bytes.
The value is expressed in decimal by default.
A binary value may be expressed with a \fB0b\fR prefix.
A hexadecimal value may be expressed using a \fB0x\fR prefix.
Negative type/data values must appear at the end of the command line, after option "\fB--\fR", to avoid parsing errors.
The offset increments by 2 prior to the next insertion.

.TP
\fBlong \fIinteger\fR
A signed or unsigned integer stored as 32 bits or 4 bytes.
The value is expressed in decimal by default.
A binary value may be expressed with a \fB0b\fR prefix.
A hexadecimal value may be expressed using a \fB0x\fR prefix.
Negative type/data values must appear at the end of the command line, after option "\fB--\fR", to avoid parsing errors.
The offset increments by 4 prior to the next insertions.

.TP
\fBhuge \fIinteger\fR
A signed or unsigned integer stored as 64 bits or 8 bytes.
The value is expressed in decimal by default.
A binary value may be expressed with a \fB0b\fR prefix.
A hexadecimal value may be expressed using a \fB0x\fR prefix.
The offset increments by 8 prior to the next insertion.
Negative type/data values must appear at the end of the command line, after option "\fB--\fR", to avoid parsing errors.
This format is only available on hosts that support 64 bit data values.

.TP
\fBdata \fIhex\fR
A sequence of hexadecimal octets.
Octets may be separated by a colon for clarity.
The number of octets determines the number of bytes written.
The offset increments by the number of bytes written.
This is similar to "\fBkey\fR" and "\fBmac\fR" below but accepts variable length input.

.TP
\fBkey \fIhex\fR
A sequence of hexadecimal octets.
Octets may be separated by a colon for clarity.
The number of octets must convert to 16 bytes or an error will occur.
The offset increments by 16 prior to the next insertion.
This is similar "\fBdata\fR" above but accepts only fixed length input.
This option may be used to set the DAK, NMK or NVAK values.

.TP
\fBmac \fIhex\fR
A sequence of hexadecimal octets.
Octets may be separated by a colon for clarity.
The number of octets must convert to 6 bytes or an error will occur.
The offset increments by 6 prior to the next insertion.
This is similar "\fBdata\fR" above but accepts only fixed length input.
This option may be used to set the DAK, NMK or NVAK values.

.TP
\fBtext \fIstring\fR
An ASCII character string.
The string string length determines the number of bytes stored.
The string is stored with NUL terminator included.
It is not padded or truncated.
The offset increments by the number of bytes stored prior to the next insertion.
This option may be used to enter a variable length string.

.TP
\fBhfid \fIstring\fR
An ASCII character string.
The string is always stored as 64 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 64 bytes prior to the next insertion.
This option may be used to enter user, network and  manufacturer identification strings.

.TP
\fBzero \fIcount\fR
An unsigned integer representing the number of consecutive bytes to fill with \fB0x00\fR.
The offset increments by the number of bytes written.
This option may be used to erase regions of the PIB.

.TP
\fBfill \fIcount\fR
An unsigned integer representing the number of consecutive bytes to fill with \fB0xFF\fR.
The offset increments by the number of bytes written.
This option may be used to erase regions of the PIB.

.TP
\fBskip \fIcount\fR
An unsigned integer indicating the number of bytes to skip over before staring another change.
Intervening data data locations are unchanged.

.SH TR69 DATA TYPES

.TP
\fBaccesspassword \fIstring\fR
An ASCII character string.
The string is always stored as 257 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 257 prior to the next insertion.

.TP
\fBaccessusername \fIstring\fR
An ASCII character string.
The string is always stored as 33 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 33 prior to the next insertion.

.TP
\fBadminpassword \fIstring\fR
An ASCII character string.
The string is always stored as 33 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 33 prior to the next insertion.

.TP
\fBadminusername \fIstring\fR
An ASCII character string.
The string is always stored as 33 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 33 prior to the next insertion.

.TP
\fBpassword \fIstring\fR
An ASCII character string.
The string is always stored as 257 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 257 prior to the next insertion.

.TP
\fBurl \fIstring\fR
An ASCII character string.
The string is always stored as 257 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 257 prior to the next insertion.

.TP
\fBusername \fIstring\fR
An ASCII character string.
The string is always stored as 257 bytes.
Short strings are padded on the right with NUL characters.
Long strings are truncated on the right and the last byte is forced to NUL.
The offset increments by 257 prior to the next insertion.

.SH EXAMPLES
The following example edits file \fBabc.pib\fR by writing decimal value \fB1\fR at offset \fB01F7\fR followed by hexadecimal value \fB00B052BABE01\fR.
A partial dump is printed showing 16 bytes before and 16 bytes after the changed data because the default display windows is 16 bytes.
Unless the change occurs right at the start or end of the file, it will appear in the center of the display window.

.PP
   # setpib -v abc.pib 01F7 byte 1 data 00:B0:52:BA:BE:01
   000001D0                       00 00 00 00 00 00 00 00 00         .........
   000001E0  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   000001F0  00 00 00 00 00 00 00 01 00 B0 52 BA BE 01 00 00  ..........R.....
   00000200  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00000210  00 00 00 00 00 00 00 00 00 00 00 00 00 00        ..............

.PP
The following example sets the manufacturer HFID string in PIB file \fBdef.pib\fR.
HFID strings are 64 characters long and either truncated or padded on the right with NUL characters.
You may need to enclose the string in quotes it it contains spaces.

.PP
   # setpib -v def.pib 24 hfid "Galactic Software Pirates, Inc."
   00000000              38 1F 00 00 30 1B EB 04 00 B0 52 00      8...0.....R.
   00000010  00 66 50 D3 E4 93 3F 85 5B 70 40 78 4D F8 15 AA  .fP...?.[p@xM...
   00000020  8D B7 00 00 47 61 6C 61 63 74 69 63 20 53 6F 66  ....Galactic Sof
   00000030  74 77 61 72 65 20 50 69 72 61 74 65 73 2C 20 49  tware Pirates, I
   00000040  6E 63 2E 00 00 00 00 00 00 00 00 00 00 00 00 00  nc..............
   00000050  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00000060  00 00 00 00 50 D3 E4 93 3F 85 5B 70 40 78 4D F8  ....P...?.[p@xM.
   00000070  15 AA 8D B7 49 6E 74 65 6C 6C 6F 6E 20 45 6E 61  ....Atheros Ena
   00000080  62 6C 65 64                                      bled

.PP
The following example displays the contents of PIB file \fBabc.pib\fR without changing any data.
The region displayed is 24 bytes starting at offset 0x24.
The format \fBskip\fR specifies the region but does not change it.
By default, the 32 bytes before and 32 bytes after are included in the display.
This technique can be used to inspect a specific portion of a PIB file.

.PP
   # setpib -v abc.pib 24 skip 64
   00000000              38 1F 00 00 30 1B EB 04 00 B0 52 00      8...0.....R.
   00000010  00 66 50 D3 E4 93 3F 85 5B 70 40 78 4D F8 15 AA  .fP...?.[p@xM...
   00000020  8D B7 00 00 47 61 6C 61 63 74 69 63 20 53 6F 66  ....Galactic Sof
   00000030  74 77 61 72 65 20 50 69 72 61 74 65 73 2C 20 49  tware Pirates, I
   00000040  6E 63 2E 00 00 00 00 00 00 00 00 00 00 00 00 00  nc..............
   00000050  00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
   00000060  00 00 00 00 50 D3 E4 93 3F 85 5B 70 40 78 4D F8  ....P...?.[p@xM.
   00000070  15 AA 8D B7 49 6E 74 65 6C 6C 6F 6E 20 45 6E 61  ....Atheros Ena
   00000080  62 6C 65 64                                      bled

.PP
The next example does the same thing for a negative value.
This is tricky because the minus sign will be interpreted as the start of another option.
We must use "\fB--\fR" to end normal option parsing.
This is a POSIX standard feature.
See \fIIEEE Std 1002.1-2001, Section 12.2, Utility Syntax Guidelines\fR for more an explanation.

.PP
   # setpib -v abc.pib 1471 -- long -50
   00001450    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ...............
   00001460 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   00001470 00 CE FF FF FF 00 00 00 00 00 00 00 00 00 00 00 ................
   00001480 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
   00001490 00 00 00 00 00                                  .....

.PP
The following example computes a new checksum without changing any data.
The filename and an offset are required but no other values are needed.
This technique can be used to compute a new checksum after modifying the file using software that does not update the checksum.

.PP
   # setpib abc.pib 0 -x

.SH DISCLAIMER
PIB file structure and content is proprietary to Qualcomm Atheros, Ocala FL USA.
Consequently, public information is not available.
Qualcomm Atheros reserves the right to modify PIB file structure or content in future firmware releases without any obligation to notify or compensate users of this program.

.SH SEE ALSO
.BR chkpib (7),
.BR chkpib2 (7),
.BR getpib (7 ),
.BR modpib ( 1 ),
.BR pib2xml ( 1 ),
.BR pibcomp ( 1 ),
.BR pibdump ( 1 ),
.BR xml2pib ( 1 )

.SH CREDITS
 Charles Maier
]

